﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
namespace MyWeb.Data
{
	public class AdvertiseDAL : SqlDataProvider
	{

		#region[Advertise_GetbyAll]
		public DataTable Advertise_GetByAll()
		{
			using (var cmd = new SqlCommand("sp_Advertise_GetByAll", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[Advertise_GetbyId]
		public DataTable Advertise_GetById(AdvertiseInfo Data)
		{
			using (var cmd = new SqlCommand("sp_Advertise_GetById", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@ID", Data.ID));
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[Advertise_GetbyTop]
		public DataTable Advertise_GetByTop(string Top, string Where, string Order)
		{
			using (var cmd = new SqlCommand("sp_Advertise_GetByTop", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				var da = new SqlDataAdapter(cmd);
				cmd.Parameters.Add(new SqlParameter("@Top",Top));
				cmd.Parameters.Add(new SqlParameter("@Where",Where));
				cmd.Parameters.Add(new SqlParameter("@Order",Order));
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[Advertise_Insert]
		public void Advertise_Insert(AdvertiseInfo Data)
		{
			using (var cmd = new SqlCommand("sp_Advertise_Insert", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@Name", Data.Name));
				cmd.Parameters.Add(new SqlParameter("@Url", Data.Url));
				cmd.Parameters.Add(new SqlParameter("@Width", Data.Width));
				cmd.Parameters.Add(new SqlParameter("@Height", Data.Height));
				cmd.Parameters.Add(new SqlParameter("@Link", Data.Link));
				cmd.Parameters.Add(new SqlParameter("@Target", Data.Target));
				cmd.Parameters.Add(new SqlParameter("@Postition", Data.Postition));
				cmd.Parameters.Add(new SqlParameter("@Order", Data.Order));
				cmd.Parameters.Add(new SqlParameter("@Status", Data.Status));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
		#region[Advertise_Update]
		public void Advertise_Update(AdvertiseInfo Data)
		{
			using (var cmd = new SqlCommand("sp_Advertise_Update", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@ID", Data.ID));
				cmd.Parameters.Add(new SqlParameter("@Name", Data.Name));
				cmd.Parameters.Add(new SqlParameter("@Url", Data.Url));
				cmd.Parameters.Add(new SqlParameter("@Width", Data.Width));
				cmd.Parameters.Add(new SqlParameter("@Height", Data.Height));
				cmd.Parameters.Add(new SqlParameter("@Link", Data.Link));
				cmd.Parameters.Add(new SqlParameter("@Target", Data.Target));
				cmd.Parameters.Add(new SqlParameter("@Postition", Data.Postition));
				cmd.Parameters.Add(new SqlParameter("@Order", Data.Order));
				cmd.Parameters.Add(new SqlParameter("@Status", Data.Status));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
		#region[Advertise_Delete]
		public void Advertise_Delete(AdvertiseInfo Data)
		{
			using (var cmd = new SqlCommand("sp_Advertise_Delete", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@ID", Data.ID));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
	}
}